import 'dart:io';
import 'dart:math';

import 'package:flutter/material.dart';

void main() {
  runApp(new ClipRRectPlugin());
}

/*
 * 圆角矩形裁剪组件 <br/>
 * 需要传入的键：<br/>
 * 传入的值类型： <br/>
 * 传入的值含义：<br/>
 * 是否必传 ：
 */
class ClipRRectPlugin extends StatefulWidget {
  State<StatefulWidget> createState() {
    return new ClipRRectPluginState();
  }
}

/*
 * 页面功能 <br/>
 */
class ClipRRectPluginState extends State<StatefulWidget> {
  void initState() {
    super.initState();
  }

  Widget build(BuildContext context) {
    AppBar appBar = AppBar(
      leading: new IconButton(
        icon: new Icon(Icons.arrow_back),
        onPressed: () {},
      ),
      title: new Text('FlutterDesign'),
      centerTitle: true,
      actions: <Widget>[
        new Container(width: 0, height: 0),
        new Container(width: 0, height: 0),
      ],
      backgroundColor: Colors.blue,
    );

    return MaterialApp(
      home: new Scaffold(
        appBar: appBar,
        body: new Builder(builder: (BuildContext context) {
          return ClipRect(
            clipper: new TrianglePath(),
            child: Image.network(
                "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1586589830556&di=bb014888b7d83178fc3419aa7a39ba97&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn07%2F53%2Fw1000h1453%2F20180416%2F0dd9-fzcyxmv1747720.jpg"),
          );
        }),
        backgroundColor: Colors.white,
        bottomNavigationBar: null,
      ),
    );
  }
}

class TrianglePath extends CustomClipper<Rect> {
  @override
  Rect getClip(Size size) {
    return Rect.fromCircle(center: Offset(150, 150), radius: 150);
  }

  @override
  bool shouldReclip(CustomClipper<Rect> oldClipper) {
    return true;
  }
}

